/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package smary.ejb.entity;

import java.io.Serializable;
import java.util.Set;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 *  Das Scrumteam enthält eine Liste aller User per N zu 1,
 * sowie Das Projekt per 1 zu N und Bennenung und Beschreibung.
 * Die Sprints sind ebenfalls per 1 zu N angebunden.
 * @author Alex
 */
@Entity
@Table(name = "SCRUMTEAM")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Scrumteam.findAll", query = "SELECT s FROM Scrumteam s"),
    @NamedQuery(name = "Scrumteam.findByScrumteamid", query = "SELECT s FROM Scrumteam s WHERE s.scrumteamid = :scrumteamid"),
//    @NamedQuery(name = "Scrumteam.findByScrumprojektid", query = "SELECT s FROM Scrumteam s WHERE s.scrumprojektid = :scrumprojektid"),
//    @NamedQuery(name = "Scrumteam.findByScrumteambezeichnung", query = "SELECT s FROM Scrumteam s WHERE s.scrumteambezeichnung = :scrumteambezeichnung"),
    @NamedQuery(name = "Scrumteam.findByScrumteambeschreibung", query = "SELECT s FROM Scrumteam s WHERE s.scrumteambeschreibung = :scrumteambeschreibung")})
public class Scrumteam implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "SCRUMTEAMID")
    @GeneratedValue(strategy= GenerationType.AUTO)
    private Integer scrumteamid;
    @NotNull
    @Size(max = 1024)
    @Column(name = "SCRUMTEAMBEZEICHNUNG")
    private String scrumteambezeichnung;

    
    @Size(min = 1, max = 32700)
    @Column(name = "SCRUMTEAMBESCHREIBUNG")
    private String scrumteambeschreibung;

    @ManyToMany(mappedBy="scrumteams")
    protected Set<Sprint> sprints;
    
    @OneToMany(mappedBy="scrumteam")
    protected Set<Userloginaccount> userloginaccounts;
    
    @ManyToOne
    @JoinColumn(name="SCRUMPROJEKT",referencedColumnName="SCRUMPROJEKTID")
    Scrumprojekt scrumprojekt;

    public Scrumprojekt getScrumprojekt() {
        return scrumprojekt;
    }

    public void setScrumprojekt(Scrumprojekt scrumprojekt) {
        this.scrumprojekt = scrumprojekt;
    }

    public Set<Sprint> getSprints() {
        return sprints;
    }

    public void setSprints(Set<Sprint> sprints) {
        this.sprints = sprints;
    }

    public Set<Userloginaccount> getUserloginaccounts() {
        return userloginaccounts;
    }

    public void setUserloginaccounts(Set<Userloginaccount> userloginaccounts) {
        this.userloginaccounts = userloginaccounts;
    }
    
    public Scrumteam() {
    }

    public Scrumteam(Integer scrumteamid) {
        this.scrumteamid = scrumteamid;
    }
    public Scrumteam(Integer scrumteamid, String scrumteambezeichnung) {
        this.scrumteamid = scrumteamid;
        this.scrumteambezeichnung = scrumteambezeichnung;
    }
    public Integer getScrumteamid() {
        return scrumteamid;
    }

    public void setScrumteamid(Integer scrumteamid) {
        this.scrumteamid = scrumteamid;
    }


    public String getScrumteambezeichnung() {
        return scrumteambezeichnung;
    }

    public void setScrumteambezeichnung(String scrumteambezeichnung) {
        this.scrumteambezeichnung = scrumteambezeichnung;
    }

    public String getScrumteambeschreibung() {
        return scrumteambeschreibung;
    }

    public void setScrumteambeschreibung(String scrumteambeschreibung) {
        this.scrumteambeschreibung = scrumteambeschreibung;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (scrumteamid != null ? scrumteamid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Scrumteam)) {
            return false;
        }
        Scrumteam other = (Scrumteam) object;
        if ((this.scrumteamid == null && other.scrumteamid != null) || (this.scrumteamid != null && !this.scrumteamid.equals(other.scrumteamid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return getScrumteamid() + "  " + getScrumteambezeichnung();
    }
    
}
